package com.zhuang.chapter14.work05;

import java.util.Iterator;

public class SequenceListTest {
	public static void main(String[] args) {
		test01();
	}

	public static void test01() {
		SequenceList<Integer> sequenceList = new SequenceList<Integer>(10);
		System.out.println("添加元素");
		for (int i = 0; i < 10; i++) {
			sequenceList.insert(i);
		}
		sequenceList.print();
		System.out.println();
		System.out.println("清空集合");
		sequenceList.clear();
		System.out.println("集合大小:" + sequenceList.length());
		System.out.println("添加元素");
		for (int i = 10; i < 20; i++) {
			sequenceList.insert(i);
		}
		sequenceList.print();
		System.out.println();
		System.out.println("集合大小:" + sequenceList.length());
		System.out.println("集合是否为空:" + sequenceList.isEmpty());
		System.out.println("索引5的元素是:" + sequenceList.get(5));
		System.out.println("删除索引5的元素:" + sequenceList.remove(5));
		sequenceList.print();
		System.out.println();

		System.out.println("迭代器遍历");
		// 迭代器遍历
		Iterator<Integer> iterator = sequenceList.iterator();
		while (iterator.hasNext()) {
			System.out.println(iterator.next());
		}
	}
}
